#region license
# This file is part of Grawlix.
# 
# Grawlix is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# 
# Grawlix is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public
# License along with Grawlix.  If not, see
# <http://www.gnu.org/licenses/>.
#endregion

"""A built-in client governor used as a fallback."""

namespace Grawlix.Application
import Grawlix.Meta
import Grawlix.Application.Gui
import Grawlix.Services
import Grawlix.Services.Rendering
import System

class BuiltInGovernor(UIGovernor):
"""A built-in governor for the client."""
	
	def constructor([required] game as Game):
	"""
	Set up the built in governor.
	Param name: The name given to this governor.
	Param game: The game this governor is part of.
	"""
		super(game)
		uri = Uri("game://Grawlix.example")
		texture = Game.FindResource[of ITextureResource](uri)
		GuiManager.TopLevel = TextureControl(Texture: texture)
	
	override def Run(message as Message):
	"""
	Default message handling.
	Param message: The message to handle.
	"""
		super(message)
		# Built-in client shouldn't get unexpected
		# messages like this.
		log Warn, ("The built-in client ($self) received " +
		           "an unexpected message (${message}). " +
		           "This is a minor error in Grawlix itself " +
		           "which should not occur. " +
		           "If you manually changed the internal engine, " +
		           "the built-in client should be updated to handle all " +
		           "message types. " +
		           "Otherwise, it could be an unexpected change between " +
		           "operating systems. If the Grawlix creators are not " +
		           "aware of the issue, please alert them of it.")
	
	def Run(message as KeyPressInputMessage):
	"""
	Handle keyboard input.
	Param message: The message to handle.
	"""
		log Info, "Key input message: ${message}"
	
	def Run(message as CharacterInputMessage):
	"""
	Handle keyboard input.
	Param trigger: The message to handle.
	"""
		log Info, "Character input message: ${message}"
	












